# -*- coding: utf-8 -*-
"""
Created on 2025/2/20 19:42
---------
@summary: 
---------
@author: rui_kai
"""
from openpyxl import load_workbook


class ExcelRead:
    def __init__(
            self,
            file_path
    ):
        self.file_path = file_path
        self.workbook = None
        self.sheet = None

    def load_workbook(self, file_path: str = None):
        """
        加载现有的Excel文件。

        :param file_path: Excel文件的路径。
        """
        if not file_path:
            file_path = self.file_path
        self.workbook = load_workbook(file_path, read_only=True, data_only=True, keep_links=False)
        self.sheet = self.workbook[self.workbook.sheetnames[0]]

    def close(self):
        """
        关闭工作簿。
        """
        self.workbook.close()


if __name__ == '__main__':
    excel = ExcelRead("1.xlsx")
    excel.load_workbook()

    first_column_values = []
    for row in excel.sheet.iter_rows(min_col=1, max_col=1):
        for cell in row:
            first_column_values.append(cell.value)
    print(list(set(first_column_values)))
